#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2016-2018, Intel Corporation
#
#
# pmempool_check/TEST14 -- test for checking pools with device dax
#

. ../unittest/unittest.sh

require_test_type medium

require_dax_devices 1
require_fs_type any
# memcheck covered by TEST23, pmemcheck takes too long
configure_valgrind force-disable $PMEMPOOL$EXESUFFIX

setup

LOG=out${UNITTEST_NUM}.log
rm -f $LOG && touch $LOG

POOLSET=$DIR/testset1
create_poolset $POOLSET AUTO:$DEVICE_DAX_PATH

expect_normal_exit $PMEMPOOL$EXESUFFIX rm $DEVICE_DAX_PATH
expect_normal_exit $PMEMPOOL$EXESUFFIX create obj $POOLSET
expect_normal_exit $PMEMPOOL$EXESUFFIX check -v $POOLSET >> $LOG
expect_normal_exit $PMEMPOOL$EXESUFFIX info $POOLSET &> /dev/null

expect_normal_exit $PMEMPOOL$EXESUFFIX rm $DEVICE_DAX_PATH
expect_normal_exit $PMEMPOOL$EXESUFFIX create log $POOLSET
expect_normal_exit $PMEMPOOL$EXESUFFIX check -v $POOLSET >> $LOG
expect_normal_exit $PMEMPOOL$EXESUFFIX info $POOLSET &> /dev/null

#remove the pools in the poolset while preserving the file itself
expect_normal_exit $PMEMPOOL$EXESUFFIX rm -s $POOLSET
#verify that the poolset still exists
check_files $POOLSET

expect_normal_exit $PMEMPOOL$EXESUFFIX create -w blk 512 $POOLSET
expect_normal_exit $PMEMPOOL$EXESUFFIX check -v $POOLSET >> $LOG
expect_normal_exit $PMEMPOOL$EXESUFFIX info $POOLSET &> /dev/null

check

pass
